import java.text.DecimalFormat;
import java.util.*;
abstract class Person{
	private String name;
	private int age;
	private boolean gender;
	public Person(String name, int age, boolean gender) {
		super();
		this.name = name;
		this.age = age;
		this.gender = gender;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public String toString() {
		return String.format("%s-%d-%s", name,age,gender);
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Person other = (Person) obj;
		if (age != other.age)
			return false;
		if (gender != other.gender)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
}
class Student extends Person{
	private String stuNo,clazz;
	public Student(String name, int age, boolean gender, String stuNo, String clazz) {
		super(name,age,gender);
		this.stuNo = stuNo;
		this.clazz = clazz;
	}
	public String toString() {
		return String.format("Student:%s-%s-%s", super.toString(),stuNo,clazz);
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Student other = (Student) obj;
		if(!super.equals(other)){
			return false;
		}
		if (clazz == null) {
			if (other.clazz != null)
				return false;
		} else if (!clazz.equals(other.clazz))
			return false;
		if (stuNo == null) {
			if (other.stuNo != null)
				return false;
		} else if (!stuNo.equals(other.stuNo))
			return false;
		return true;
	}
	
}
class Company{
		private String name;
		public Company(String name) {
			super();
			this.name = name;
		}
		public String toString(){
			return name;
		}
		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Company other = (Company) obj;
			if (name == null) {
				if (other.name != null)
					return false;
			} else if (!name.equals(other.name))
				return false;
			return true;
		}	
}
class Employee extends Person{
	private Company company;
	private double salary;
	public Employee(String name, int age, boolean gender, double salary, Company company) {
		super(name, age, gender);
		this.salary = salary;
		this.company = company;
	}
	public String toString() {
		return String.format("Employee:%s-%s-%s", super.toString(),company,salary);
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Employee other = (Employee) obj;
		DecimalFormat df = new DecimalFormat("#.#");
		if(!super.equals(other)){
			return false;
		}
		if (company == null) {
			if (other.company != null)
				return false;
		} else if (!company.equals(other.company))
			return false;
		if (!df.format(salary).equals(df.format(other.salary)))
			return false;
		return true;
	}
	
}
public class pta356 {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
	    Scanner in=new Scanner(System.in);
	    	ArrayList<Object> personList=new ArrayList<Object>();
	        while(in.hasNext()){
	    	String str=in.next();
	    	if(str.equals("s")){
	    		Student student=new Student(in.next(), in.nextInt(), in.nextBoolean(), in.next(), in.next());
	    		personList.add(student);
	    	}
	    	else if(str.equals("e")) {
	    		Employee employee=new Employee(in.next(), in.nextInt(), in.nextBoolean(), in.nextDouble(),new Company(in.next()));
	    		personList.add(employee);
	    	}
	    	else break;}
	    	Collections.sort(personList,new myComparator());
	        for (int i = 0; i < personList.size(); i++) {
				System.out.println(personList.get(i));
			}
	    	ArrayList<Student> stuList=new ArrayList<Student>();
    		ArrayList<Employee> empList=new ArrayList<Employee>();
	    	if(in.next().equals("exit")){
	    		 System.exit(0);
	    	}
	    	else{
	    		for (int i = 0; i < personList.size(); i++) {
					if(personList.get(i).getClass().getName().equals("Employee")){
						if(!empList.contains(personList.get(i))){
					    	empList.add((Employee)personList.get(i));
						}
					}
					else if(personList.get(i).getClass().getName().equals("Student")){
						 if(!stuList.contains(personList.get(i))){
							 stuList.add((Student)personList.get(i));
						 }
						 
					}
					
				}
	    	}
	    	System.out.println("stuList");
			for (int i = 0; i < stuList.size(); i++) {
				System.out.println(stuList.get(i));
			}
			System.out.println("empList");
			for (int i = 0; i < empList.size(); i++) {
				System.out.println(empList.get(i));
			}
	        
	    in.close();
	}
	static class myComparator implements Comparator{
		@Override
		public int compare(Object o1, Object o2) {
			Person o3= (Person) o1;
			Person o4= (Person) o2;
			if(o3.getName().compareTo(o4.getName())!=0){
				return  o3.getName().compareTo(o4.getName());
			}
			else {
				return Integer.toString(o3.getAge()).compareTo(Integer.toString(o4.getAge())) ;
			}
		}
	}
	
}
